package com.kevin.chat;

import java.util.HashSet;
import java.util.Set;

/**
 * 用户
 * 
 * @author kevin
 * 
 */
public class User {

	private String userid;

	private String username;

	public String getUserid() {
		return userid;
	}

	public void setUserid(String userid) {
		this.userid = userid;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public User(String userid, String username) {
		super();
		this.userid = userid;
		this.username = username;
	}

	@Override
	public boolean equals(Object obj) {
		// TODO Auto-generated method stub
		if(obj instanceof User){
			return ((User) obj).getUserid().equals(this.getUserid());
		}else
			return super.equals(obj);
	}	
	
	public int hashCode() {
		return userid.hashCode();
	}

	public static void main(String[] args) {
		Set<User> users = new HashSet<User>();
		User user = new User("3", "1234");
		User user1 = new User("3", "derewr");
		users.add(user);
		users.add(user1);
		users.remove(user1);
//		Set<Object> users0 = new HashSet<Object>();
//		String s0 = new String("abcd");
//		String s1 = new String("abcd");
//		users0.add("abc");
//		users0.add("abc");
//		users0.add("abc");
//		users0.add("abc");
//		users0.add(s0);
//		users0.add(s1);
	}

}
